package com.mcc.app.siloReport.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.util.PerformanceSensitive;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.siloReport.domain.SiloDayReport;
import com.mcc.app.siloReport.service.ISiloDayReportService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 配料日报
 *
 * @author gxy
 * @date 2025-03-25
 */
@Api(tags = "配料日报")
@RestController
@RequestMapping("/siloReport/siloReport")
public class SiloDayReportController extends BaseController {

    @Autowired
    private ISiloDayReportService siloDayReportService;

    @ApiOperation("查询配料日报列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('siloReport:siloReport:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<SiloDayReport>> list(SiloDayReport siloDayReport) {
        List<SiloDayReport> list = siloDayReportService.selectSiloDayReportList(siloDayReport);
        return getDataTable(list);
    }

    @ApiOperation("查询配料日报列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('siloReport:siloReport:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<SiloDayReport>> page(SiloDayReport siloDayReport) {
        startPage();
        List<SiloDayReport> list = siloDayReportService.selectSiloDayReportList(siloDayReport);
        return getDataTable(list);
    }

    @ApiOperation("获取配料日报详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('siloReport:siloReport:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<SiloDayReport> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(siloDayReportService.selectSiloDayReportById(id));
    }

    @ApiOperation("新增配料日报")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('siloReport:siloReport:add')")
    @Log(title = "配料日报", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SiloDayReport siloDayReport) {
        return toAjax(siloDayReportService.insertSiloDayReport(siloDayReport));
    }

    @ApiOperation("修改配料日报")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('siloReport:siloReport:edit')")
    @Log(title = "配料日报", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody SiloDayReport siloDayReport) {
        return toAjax(siloDayReportService.updateSiloDayReport(siloDayReport));
    }

    @ApiOperation("删除配料日报")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('siloReport:siloReport:remove')")
    @Log(title = "配料日报", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(siloDayReportService.deleteSiloDayReportByIds(ids));
    }

    @ApiOperation("导出报表")
    @Log(title = "配料日报", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SiloDayReport siloDayReport) {
        return AjaxResult.success(siloDayReportService.exportSiloDayReport(siloDayReport));
    }
}
